package sky.treasure;

/**
 * Created with IntelliJ IDEA.
 * User: Gauss
 * Date: 23.12.13
 * Time: 0:27
 * To change this template use File | Settings | File Templates.
 */
public class Coordinates {

    protected int x;
    protected int y;

    public Coordinates(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Coordinates(Coordinates coordinates) {
        this.x = coordinates.x;
        this.y = coordinates.y;
    }

    @Override
    public boolean equals(Object obj) {
        return obj instanceof Coordinates && ((Coordinates)obj).x==this.x && ((Coordinates)obj).y==this.y;
    }

    @Override
    public int hashCode() {
        int result = x;
        result = 31 * result + y;
        return result;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void incrementX() {
        x++;
    }

    public void decrementX() {
        x--;
    }

    public void incrementY() {
        y++;
    }

    public void decrementY() {
        y--;
    }

    public void changeCoordinates(Coordinates coordinates) {
        this.x = coordinates.getX();
        this.y = coordinates.getY();
    }
}
